const {
    Role
} = require('../../../model/Role');

module.exports = async (req, res) => {
    const updates = req.fields.roles;
    if (updates.length < 1) return res.sendResult(null, 400, '提交的参数不能为空');
    const resData = [];
    let index = 0;
    while (index < updates.length) {
        const role = updates[index];
        const data = await Role.findOneAndUpdate({
            rid: role.rid
        }, role, {
            new: true
        });
        resData.push(data);
        index++;
    }
    return res.sendResult(resData, 200, '修改成功');
}